﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RedHouse.Data.Common;
using RedHouse.Data;

namespace RedHouse.Web
{
    public partial class MailConfirm : System.Web.UI.Page
    {
        private string _successMessageTemplate = "<script>alert('Email confirmed! Thanks for your subcription!')</script>";
        private string _errorMessageTemplate = "<script>alert('Error while process your request!')</script>";

        protected void Page_Load(object sender, EventArgs e)
        {
            string emailAddress = Request["email"];
            Subcribe subcribe = new Subcribe()
            {
                Email = emailAddress
            };
            OperationResult confirmResult = RedHouse.Data.Base.SubcribeService.Instance.ActiveSubcribe(subcribe);
            if (confirmResult.Result)
            {
                Response.Write(_successMessageTemplate);
            }
            else
            {
                Response.Write(_errorMessageTemplate);
            }

            Response.Redirect("~/Home.aspx");

        }
    }
}